package com.egao.common.module.guidance.controller;

import com.egao.common.core.annotation.OperLog;
import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.common.core.web.PageParam;
import com.egao.common.core.web.PageResult;
import com.egao.common.module.company.entity.Preach;
import com.egao.common.module.student.service.StudentMatchingService;
import com.egao.common.publicly.entity.PubliclyCareerVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 推送信息
 * @author pyx
 */
@Api(tags = "推送信息")
@RestController
@RequestMapping("${api}")
public class StudentMatchingController extends BaseController {
    @Autowired
    private StudentMatchingService studentMatchingService;

    @PreAuthorize("hasAuthority('student:matching:list')")
    @ApiOperation("分页就业讲座")
    @OperLog(value = "就业讲座管理", desc = "分页查询就业讲座信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页", required = false, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "limit", value = "每页条数", required = false, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "id", value = "学生id", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "类型", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "title", value = "标题", required = false, dataType = "String", paramType = "query"),
    })
    @GetMapping("/student/matching/page")
    public PageResult<PubliclyCareerVO> page(HttpServletRequest request){
        PageParam<PubliclyCareerVO> pageParam = new PageParam<>(request);
        return new PageResult<>(studentMatchingService.listPageAll(pageParam,getLoginUserId()), pageParam.getTotal());
    }

    @PreAuthorize("hasAuthority('student:matching:list')")
    @ApiOperation("修改推送信息状态")
    @GetMapping("/student/matching/push")
    public JsonResult pushRead(Integer pushMsgId, Integer year){
        return studentMatchingService.pushReadByYear(pushMsgId, year);
    }
}
